﻿Imports log4net

Partial Class P02_Edit
    Inherits System.Web.UI.Page

    Public scripttext As String

    Private Shared logger As ILog = LogManager.GetLogger("P02_Edit")

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Session("users") Is Nothing Then
            scripttext = "<script>ClosePop();</script>"
        End If
        Session.LCID = 2057
        year1.Text = Val(Request("PlanYear") - 1).ToString
        year2.Text = Request("PlanYear")
        Dim re_adap As New FormLockDSTableAdapters.FundCenterReleasesTableAdapter
        If re_adap.CountRelease(Val(Request("PlanYear")), Request("Version"), Request("FCTR")) > 0 Then
            SaveDocument.Visible = False
        End If
        If IsPostBack = False Then
            LoadData()
            scripttext = "<script>CalSum();</script>"
        End If

    End Sub

    Sub LoadData()
        Dim adapter As New PDataSetTableAdapters.BudgetRevPlans2TableAdapter
        Dim datatable As New PDataSet.BudgetRevPlans2DataTable

        Dim sql As String
        sql = " select BudgetRevPlans.id,BudgetRevPlans.FundCenter_FundCenterCode,FundCenters.Description As FCName,BudgetRevplans.Product_ProductCode AS ProductCode,Products.Description As ProductDesc,BudgetRevPlans.ProductItem_Id,ProductItems.Description As ProItemDesc"
        sql += " ,ActualLastYear2,ActualLastYear1,ForecastLastYear1,ForecastCurYear,LastYearMonth1,LastYearMonth2,LastYearMonth3,LastYearMonth4,LastYearMonth5,LastYearMonth6,LastYearMonth7,LastYearMonth8,LastYearMonth9,LastYearMonth10,LastYearMonth11,LastYearMonth12,CurYearMonth1,CurYearMonth2,CurYearMonth3,CurYearMonth4,CurYearMonth5,CurYearMonth6,CurYearMonth7,CurYearMonth8,CurYearMonth9,CurYearMonth10,CurYearMonth11,CurYearMonth12,(ActualLastYear1+ForecastLastYear1) As SumFX"
        sql += " , ProductItems.ItemNo"
        sql += " From budgetRevPlans INNER JOIN FundCenters ON BudgetRevPlans.FundCenter_FundCenterCode = FundCenters.FundCenterCode"
        sql += " INNER JOIN Products ON BudgetRevPlans.Product_ProductCode = Products.ProductCode INNER JOIN ProductItems ON BudgetRevplans.ProductItem_Id = ProductItems.Id"
        sql += " AND BudgetRevPlans.FundCenter_FundCenterCode = '" & Request("FCTR") & "'"
        sql += " AND BudgetRevPlans.Product_ProductCode = '" & Request("Product") & "'"
        sql += " And ProductItems.FormID = 'P02' "

        sql += " AND BudgetRevPlans.PlanYear = " & Request("PlanYear") & " "
        sql += " AND BudgetRevPlans.Version = '" & Request("Version") & "'"
        sql += " AND FundCenters.PlanYear = " & Request("PlanYear") & " "
        sql += " AND Products.PlanYear = " & Request("PlanYear") & " "
        sql += " AND ProductItems.PlanYear = " & Request("PlanYear") & " "
        sql += " AND Products.FormP02Flag = 'Y' "

        'Response.Write(sql)
        adapter.GetDataByFilter(datatable, sql)
        If datatable.Count > 0 Then
            name1.Text = datatable.Item(0).FundCenter_FundCenterCode & " - " & datatable.Item(0).ProductDesc
        End If

        For Each item As PDataSet.BudgetRevPlans2Row In datatable
            Select Case item.ItemNo
                Case 3
                    A_ID.Text = item.id
                    A_LAST2.Text = item.ActualLastYear2
                    A1.Value = Format(item.LastYearMonth1 / 1000, "#,##0.##")
                    A2.Value = Format(item.LastYearMonth2 / 1000, "#,##0.##")
                    A3.Value = Format(item.LastYearMonth3 / 1000, "#,##0.##")
                    A4.Value = Format(item.LastYearMonth4 / 1000, "#,##0.##")
                    A5.Value = Format(item.LastYearMonth5 / 1000, "#,##0.##")
                    ASUM0.Value = Format(item.ActualLastYear1 / 1000, "#,##0.##")

                    A6.Value = Format(item.LastYearMonth6 / 1000, "#,##0.##")
                    A7.Value = Format(item.LastYearMonth7 / 1000, "#,##0.##")
                    A8.Value = Format(item.LastYearMonth8 / 1000, "#,##0.##")
                    A9.Value = Format(item.LastYearMonth9 / 1000, "#,##0.##")
                    A10.Value = Format(item.LastYearMonth10 / 1000, "#,##0.##")
                    A11.Value = Format(item.LastYearMonth11 / 1000, "#,##0.##")
                    A12.Value = Format(item.LastYearMonth12 / 1000, "#,##0.##")
                    ASUM1.Value = Format(item.ForecastLastYear1 / 1000, "#,##0.##")

                    A13.Value = Format(item.CurYearMonth1 / 1000, "#,##0.##")
                    A14.Value = Format(item.CurYearMonth2 / 1000, "#,##0.##")
                    A15.Value = Format(item.CurYearMonth3 / 1000, "#,##0.##")
                    A16.Value = Format(item.CurYearMonth4 / 1000, "#,##0.##")
                    A17.Value = Format(item.CurYearMonth5 / 1000, "#,##0.##")
                    A18.Value = Format(item.CurYearMonth6 / 1000, "#,##0.##")
                    A19.Value = Format(item.CurYearMonth7 / 1000, "#,##0.##")
                    A20.Value = Format(item.CurYearMonth8 / 1000, "#,##0.##")
                    A21.Value = Format(item.CurYearMonth9 / 1000, "#,##0.##")
                    A22.Value = Format(item.CurYearMonth10 / 1000, "#,##0.##")
                    A23.Value = Format(item.CurYearMonth11 / 1000, "#,##0.##")
                    A24.Value = Format(item.CurYearMonth12 / 1000, "#,##0.##")
                    ASUM2.Value = Format(item.ForecastCurYear / 1000, "#,##0.##")

                Case 1
                    B_ID.Text = item.id
                    B_LAST2.Text = item.ActualLastYear2
                    B1.Value = Format(item.LastYearMonth1 / 1000, "#,##0.##")
                    B2.Value = Format(item.LastYearMonth2 / 1000, "#,##0.##")
                    B3.Value = Format(item.LastYearMonth3 / 1000, "#,##0.##")
                    B4.Value = Format(item.LastYearMonth4 / 1000, "#,##0.##")
                    B5.Value = Format(item.LastYearMonth5 / 1000, "#,##0.##")
                    BSUM0.Value = Format(item.ActualLastYear1 / 1000, "#,##0.##")

                    B6.Value = Format(item.LastYearMonth6 / 1000, "#,##0.##")
                    B7.Value = Format(item.LastYearMonth7 / 1000, "#,##0.##")
                    B8.Value = Format(item.LastYearMonth8 / 1000, "#,##0.##")
                    B9.Value = Format(item.LastYearMonth9 / 1000, "#,##0.##")
                    B10.Value = Format(item.LastYearMonth10 / 1000, "#,##0.##")
                    B11.Value = Format(item.LastYearMonth11 / 1000, "#,##0.##")
                    B12.Value = Format(item.LastYearMonth12 / 1000, "#,##0.##")
                    BSUM1.Value = Format(item.ForecastLastYear1 / 1000, "#,##0.##")

                    B13.Value = Format(item.CurYearMonth1 / 1000, "#,##0.##")
                    B14.Value = Format(item.CurYearMonth2 / 1000, "#,##0.##")
                    B15.Value = Format(item.CurYearMonth3 / 1000, "#,##0.##")
                    B16.Value = Format(item.CurYearMonth4 / 1000, "#,##0.##")
                    B17.Value = Format(item.CurYearMonth5 / 1000, "#,##0.##")
                    B18.Value = Format(item.CurYearMonth6 / 1000, "#,##0.##")
                    B19.Value = Format(item.CurYearMonth7 / 1000, "#,##0.##")
                    B20.Value = Format(item.CurYearMonth8 / 1000, "#,##0.##")
                    B21.Value = Format(item.CurYearMonth9 / 1000, "#,##0.##")
                    B22.Value = Format(item.CurYearMonth10 / 1000, "#,##0.##")
                    B23.Value = Format(item.CurYearMonth11 / 1000, "#,##0.##")
                    B24.Value = Format(item.CurYearMonth12 / 1000, "#,##0.##")
                    BSUM2.Value = Format(item.ForecastCurYear / 1000, "#,##0.##")

                Case 2
                    C_ID.Text = item.id
                    C_LAST2.Text = item.ActualLastYear2
                    C1.Value = Format(item.LastYearMonth1 / 1000, "#,##0.##")
                    C2.Value = Format(item.LastYearMonth2 / 1000, "#,##0.##")
                    C3.Value = Format(item.LastYearMonth3 / 1000, "#,##0.##")
                    C4.Value = Format(item.LastYearMonth4 / 1000, "#,##0.##")
                    C5.Value = Format(item.LastYearMonth5 / 1000, "#,##0.##")
                    CSUM0.Value = Format(item.ActualLastYear1 / 1000, "#,##0.##")

                    C6.Value = Format(item.LastYearMonth6 / 1000, "#,##0.##")
                    C7.Value = Format(item.LastYearMonth7 / 1000, "#,##0.##")
                    C8.Value = Format(item.LastYearMonth8 / 1000, "#,##0.##")
                    C9.Value = Format(item.LastYearMonth9 / 1000, "#,##0.##")
                    C10.Value = Format(item.LastYearMonth10 / 1000, "#,##0.##")
                    C11.Value = Format(item.LastYearMonth11 / 1000, "#,##0.##")
                    C12.Value = Format(item.LastYearMonth12 / 1000, "#,##0.##")
                    CSUM1.Value = Format(item.ForecastLastYear1 / 1000, "#,##0.##")

                    C13.Value = Format(item.CurYearMonth1 / 1000, "#,##0.##")
                    C14.Value = Format(item.CurYearMonth2 / 1000, "#,##0.##")
                    C15.Value = Format(item.CurYearMonth3 / 1000, "#,##0.##")
                    C16.Value = Format(item.CurYearMonth4 / 1000, "#,##0.##")
                    C17.Value = Format(item.CurYearMonth5 / 1000, "#,##0.##")
                    C18.Value = Format(item.CurYearMonth6 / 1000, "#,##0.##")
                    C19.Value = Format(item.CurYearMonth7 / 1000, "#,##0.##")
                    C20.Value = Format(item.CurYearMonth8 / 1000, "#,##0.##")
                    C21.Value = Format(item.CurYearMonth9 / 1000, "#,##0.##")
                    C22.Value = Format(item.CurYearMonth10 / 1000, "#,##0.##")
                    C23.Value = Format(item.CurYearMonth11 / 1000, "#,##0.##")
                    C24.Value = Format(item.CurYearMonth12 / 1000, "#,##0.##")
                    CSUM2.Value = Format(item.ForecastCurYear / 1000, "#,##0.##")

                Case 4
                    D_ID.Text = item.id
                    D_LAST2.Text = item.ActualLastYear2
                    D1.Value = Format(item.LastYearMonth1 / 1000, "#,##0.##")
                    D2.Value = Format(item.LastYearMonth2 / 1000, "#,##0.##")
                    D3.Value = Format(item.LastYearMonth3 / 1000, "#,##0.##")
                    D4.Value = Format(item.LastYearMonth4 / 1000, "#,##0.##")
                    D5.Value = Format(item.LastYearMonth5 / 1000, "#,##0.##")
                    DSUM0.Value = Format(item.ActualLastYear1 / 1000, "#,##0.##")

                    D6.Value = Format(item.LastYearMonth6 / 1000, "#,##0.##")
                    D7.Value = Format(item.LastYearMonth7 / 1000, "#,##0.##")
                    D8.Value = Format(item.LastYearMonth8 / 1000, "#,##0.##")
                    D9.Value = Format(item.LastYearMonth9 / 1000, "#,##0.##")
                    D10.Value = Format(item.LastYearMonth10 / 1000, "#,##0.##")
                    D11.Value = Format(item.LastYearMonth11 / 1000, "#,##0.##")
                    D12.Value = Format(item.LastYearMonth12 / 1000, "#,##0.##")
                    DSUM1.Value = Format(item.ForecastLastYear1 / 1000, "#,##0.##")

                    D13.Value = Format(item.CurYearMonth1 / 1000, "#,##0.##")
                    D14.Value = Format(item.CurYearMonth2 / 1000, "#,##0.##")
                    D15.Value = Format(item.CurYearMonth3 / 1000, "#,##0.##")
                    D16.Value = Format(item.CurYearMonth4 / 1000, "#,##0.##")
                    D17.Value = Format(item.CurYearMonth5 / 1000, "#,##0.##")
                    D18.Value = Format(item.CurYearMonth6 / 1000, "#,##0.##")
                    D19.Value = Format(item.CurYearMonth7 / 1000, "#,##0.##")
                    D20.Value = Format(item.CurYearMonth8 / 1000, "#,##0.##")
                    D21.Value = Format(item.CurYearMonth9 / 1000, "#,##0.##")
                    D22.Value = Format(item.CurYearMonth10 / 1000, "#,##0.##")
                    D23.Value = Format(item.CurYearMonth11 / 1000, "#,##0.##")
                    D24.Value = Format(item.CurYearMonth12 / 1000, "#,##0.##")
                    DSUM2.Value = Format(item.ForecastCurYear / 1000, "#,##0.##")

                Case 5
                    E_ID.Text = item.id
                    E_LAST2.Text = item.ActualLastYear2
                    E1.Value = Format(item.LastYearMonth1 / 1000, "#,##0.##")
                    E2.Value = Format(item.LastYearMonth2 / 1000, "#,##0.##")
                    E3.Value = Format(item.LastYearMonth3 / 1000, "#,##0.##")
                    E4.Value = Format(item.LastYearMonth4 / 1000, "#,##0.##")
                    E5.Value = Format(item.LastYearMonth5 / 1000, "#,##0.##")
                    ESUM0.Value = Format(item.ActualLastYear1 / 1000, "#,##0.##")

                    E6.Value = Format(item.LastYearMonth6 / 1000, "#,##0.##")
                    E7.Value = Format(item.LastYearMonth7 / 1000, "#,##0.##")
                    E8.Value = Format(item.LastYearMonth8 / 1000, "#,##0.##")
                    E9.Value = Format(item.LastYearMonth9 / 1000, "#,##0.##")
                    E10.Value = Format(item.LastYearMonth10 / 1000, "#,##0.##")
                    E11.Value = Format(item.LastYearMonth11 / 1000, "#,##0.##")
                    E12.Value = Format(item.LastYearMonth12 / 1000, "#,##0.##")
                    ESUM1.Value = Format(item.ForecastLastYear1 / 1000, "#,##0.##")

                    E13.Value = Format(item.CurYearMonth1 / 1000, "#,##0.##")
                    E14.Value = Format(item.CurYearMonth2 / 1000, "#,##0.##")
                    E15.Value = Format(item.CurYearMonth3 / 1000, "#,##0.##")
                    E16.Value = Format(item.CurYearMonth4 / 1000, "#,##0.##")
                    E17.Value = Format(item.CurYearMonth5 / 1000, "#,##0.##")
                    E18.Value = Format(item.CurYearMonth6 / 1000, "#,##0.##")
                    E19.Value = Format(item.CurYearMonth7 / 1000, "#,##0.##")
                    E20.Value = Format(item.CurYearMonth8 / 1000, "#,##0.##")
                    E21.Value = Format(item.CurYearMonth9 / 1000, "#,##0.##")
                    E22.Value = Format(item.CurYearMonth10 / 1000, "#,##0.##")
                    E23.Value = Format(item.CurYearMonth11 / 1000, "#,##0.##")
                    E24.Value = Format(item.CurYearMonth12 / 1000, "#,##0.##")
                    ESUM2.Value = Format(item.ForecastCurYear / 1000, "#,##0.##")

                Case 6
                    F_ID.Text = item.id
                    F_LAST2.Text = item.ActualLastYear2
                    F1.Value = Format(item.LastYearMonth1 * 100, "#,##0.##")
                    F2.Value = Format(item.LastYearMonth2 * 100, "#,##0.##")
                    F3.Value = Format(item.LastYearMonth3 * 100, "#,##0.##")
                    F4.Value = Format(item.LastYearMonth4 * 100, "#,##0.##")
                    F5.Value = Format(item.LastYearMonth5 * 100, "#,##0.##")
                    FSUM0.Value = Format(item.ActualLastYear1 * 100, "#,##0.##")

                    F6.Value = Format(item.LastYearMonth6 * 100, "#,##0.##")
                    F7.Value = Format(item.LastYearMonth7 * 100, "#,##0.##")
                    F8.Value = Format(item.LastYearMonth8 * 100, "#,##0.##")
                    F9.Value = Format(item.LastYearMonth9 * 100, "#,##0.##")
                    F10.Value = Format(item.LastYearMonth10 * 100, "#,##0.##")
                    F11.Value = Format(item.LastYearMonth11 * 100, "#,##0.##")
                    F12.Value = Format(item.LastYearMonth12 * 100, "#,##0.##")
                    FSUM1.Value = Format(item.ForecastLastYear1 * 100, "#,##0.##")

                    F13.Value = Format(item.CurYearMonth1 * 100, "#,##0.##")
                    F14.Value = Format(item.CurYearMonth2 * 100, "#,##0.##")
                    F15.Value = Format(item.CurYearMonth3 * 100, "#,##0.##")
                    F16.Value = Format(item.CurYearMonth4 * 100, "#,##0.##")
                    F17.Value = Format(item.CurYearMonth5 * 100, "#,##0.##")
                    F18.Value = Format(item.CurYearMonth6 * 100, "#,##0.##")
                    F19.Value = Format(item.CurYearMonth7 * 100, "#,##0.##")
                    F20.Value = Format(item.CurYearMonth8 * 100, "#,##0.##")
                    F21.Value = Format(item.CurYearMonth9 * 100, "#,##0.##")
                    F22.Value = Format(item.CurYearMonth10 * 100, "#,##0.##")
                    F23.Value = Format(item.CurYearMonth11 * 100, "#,##0.##")
                    F24.Value = Format(item.CurYearMonth12 * 100, "#,##0.##")

                    FSUM2.Value = Format(item.ForecastCurYear * 100, "#,##0.##")
            End Select
        Next
    End Sub

    Protected Sub SaveDocument_Click(sender As Object, e As EventArgs) Handles SaveDocument.Click
        Dim adapterX As New PDataSetTableAdapters.BudgetRevPlans1TableAdapter
        Try
            adapterX.UpdateQuery(Val(B_LAST2.Text), Val(BSUM0.Value.Replace(",", String.Empty)) * 1000, Val(BSUM1.Value.Replace(",", String.Empty)) * 1000, Val(BSUM2.Value.Replace(",", String.Empty)) * 1000, Val(B1.Value.Replace(",", String.Empty)) * 1000, Val(B2.Value.Replace(",", String.Empty)) * 1000, Val(B3.Value.Replace(",", String.Empty)) * 1000, Val(B4.Value.Replace(",", String.Empty)) * 1000, Val(B5.Value.Replace(",", String.Empty)) * 1000, Val(B6.Value.Replace(",", String.Empty)) * 1000, Val(B7.Value.Replace(",", String.Empty)) * 1000, Val(B8.Value.Replace(",", String.Empty)) * 1000, Val(B9.Value.Replace(",", String.Empty)) * 1000, Val(B10.Value.Replace(",", String.Empty)) * 1000, Val(B11.Value.Replace(",", String.Empty)) * 1000, Val(B12.Value.Replace(",", String.Empty)) * 1000, Val(B13.Value.Replace(",", String.Empty)) * 1000, Val(B14.Value.Replace(",", String.Empty)) * 1000, Val(B15.Value.Replace(",", String.Empty)) * 1000, Val(B16.Value.Replace(",", String.Empty)) * 1000, Val(B17.Value.Replace(",", String.Empty)) * 1000, Val(B18.Value.Replace(",", String.Empty)) * 1000, Val(B19.Value.Replace(",", String.Empty)) * 1000, Val(B20.Value.Replace(",", String.Empty)) * 1000, Val(B21.Value.Replace(",", String.Empty)) * 1000, Val(B22.Value.Replace(",", String.Empty)) * 1000, Val(B23.Value.Replace(",", String.Empty)) * 1000, Val(B24.Value.Replace(",", String.Empty)) * 1000, Date.Now(), Val(Session("users")), Val(B_ID.Text))
            adapterX.UpdateQuery(Val(C_LAST2.Text), Val(CSUM0.Value.Replace(",", String.Empty)) * 1000, Val(CSUM1.Value.Replace(",", String.Empty)) * 1000, Val(CSUM2.Value.Replace(",", String.Empty)) * 1000, Val(C1.Value.Replace(",", String.Empty)) * 1000, Val(C2.Value.Replace(",", String.Empty)) * 1000, Val(C3.Value.Replace(",", String.Empty)) * 1000, Val(C4.Value.Replace(",", String.Empty)) * 1000, Val(C5.Value.Replace(",", String.Empty)) * 1000, Val(C6.Value.Replace(",", String.Empty)) * 1000, Val(C7.Value.Replace(",", String.Empty)) * 1000, Val(C8.Value.Replace(",", String.Empty)) * 1000, Val(C9.Value.Replace(",", String.Empty)) * 1000, Val(C10.Value.Replace(",", String.Empty)) * 1000, Val(C11.Value.Replace(",", String.Empty)) * 1000, Val(C12.Value.Replace(",", String.Empty)) * 1000, Val(C13.Value.Replace(",", String.Empty)) * 1000, Val(C14.Value.Replace(",", String.Empty)) * 1000, Val(C15.Value.Replace(",", String.Empty)) * 1000, Val(C16.Value.Replace(",", String.Empty)) * 1000, Val(C17.Value.Replace(",", String.Empty)) * 1000, Val(C18.Value.Replace(",", String.Empty)) * 1000, Val(C19.Value.Replace(",", String.Empty)) * 1000, Val(C20.Value.Replace(",", String.Empty)) * 1000, Val(C21.Value.Replace(",", String.Empty)) * 1000, Val(C22.Value.Replace(",", String.Empty)) * 1000, Val(C23.Value.Replace(",", String.Empty)) * 1000, Val(C24.Value.Replace(",", String.Empty)) * 1000, Date.Now(), Val(Session("users")), Val(C_ID.Text))
            adapterX.UpdateQuery(Val(A_LAST2.Text), Val(ASUM0.Value.Replace(",", String.Empty)) * 1000, Val(ASUM1.Value.Replace(",", String.Empty)) * 1000, Val(ASUM2.Value.Replace(",", String.Empty)) * 1000, Val(A1.Value.Replace(",", String.Empty)) * 1000, Val(A2.Value.Replace(",", String.Empty)) * 1000, Val(A3.Value.Replace(",", String.Empty)) * 1000, Val(A4.Value.Replace(",", String.Empty)) * 1000, Val(A5.Value.Replace(",", String.Empty)) * 1000, Val(A6.Value.Replace(",", String.Empty)) * 1000, Val(A7.Value.Replace(",", String.Empty)) * 1000, Val(A8.Value.Replace(",", String.Empty)) * 1000, Val(A9.Value.Replace(",", String.Empty)) * 1000, Val(A10.Value.Replace(",", String.Empty)) * 1000, Val(A11.Value.Replace(",", String.Empty)) * 1000, Val(A12.Value.Replace(",", String.Empty)) * 1000, Val(A13.Value.Replace(",", String.Empty)) * 1000, Val(A14.Value.Replace(",", String.Empty)) * 1000, Val(A15.Value.Replace(",", String.Empty)) * 1000, Val(A16.Value.Replace(",", String.Empty)) * 1000, Val(A17.Value.Replace(",", String.Empty)) * 1000, Val(A18.Value.Replace(",", String.Empty)) * 1000, Val(A19.Value.Replace(",", String.Empty)) * 1000, Val(A20.Value.Replace(",", String.Empty)) * 1000, Val(A21.Value.Replace(",", String.Empty)) * 1000, Val(A22.Value.Replace(",", String.Empty)) * 1000, Val(A23.Value.Replace(",", String.Empty)) * 1000, Val(A24.Value.Replace(",", String.Empty)) * 1000, Date.Now(), Val(Session("users")), Val(A_ID.Text))
            adapterX.UpdateQuery(Val(D_LAST2.Text), Val(DSUM0.Value.Replace(",", String.Empty)) * 1000, Val(DSUM1.Value.Replace(",", String.Empty)) * 1000, Val(DSUM2.Value.Replace(",", String.Empty)) * 1000, Val(D1.Value.Replace(",", String.Empty)) * 1000, Val(D2.Value.Replace(",", String.Empty)) * 1000, Val(D3.Value.Replace(",", String.Empty)) * 1000, Val(D4.Value.Replace(",", String.Empty)) * 1000, Val(D5.Value.Replace(",", String.Empty)) * 1000, Val(D6.Value.Replace(",", String.Empty)) * 1000, Val(D7.Value.Replace(",", String.Empty)) * 1000, Val(D8.Value.Replace(",", String.Empty)) * 1000, Val(D9.Value.Replace(",", String.Empty)) * 1000, Val(D10.Value.Replace(",", String.Empty)) * 1000, Val(D11.Value.Replace(",", String.Empty)) * 1000, Val(D12.Value.Replace(",", String.Empty)) * 1000, Val(D13.Value.Replace(",", String.Empty)) * 1000, Val(D14.Value.Replace(",", String.Empty)) * 1000, Val(D15.Value.Replace(",", String.Empty)) * 1000, Val(D16.Value.Replace(",", String.Empty)) * 1000, Val(D17.Value.Replace(",", String.Empty)) * 1000, Val(D18.Value.Replace(",", String.Empty)) * 1000, Val(D19.Value.Replace(",", String.Empty)) * 1000, Val(D20.Value.Replace(",", String.Empty)) * 1000, Val(D21.Value.Replace(",", String.Empty)) * 1000, Val(D22.Value.Replace(",", String.Empty)) * 1000, Val(D23.Value.Replace(",", String.Empty)) * 1000, Val(D24.Value.Replace(",", String.Empty)) * 1000, Date.Now(), Val(Session("users")), Val(D_ID.Text))
            adapterX.UpdateQuery(Val(E_LAST2.Text), Val(ESUM0.Value.Replace(",", String.Empty)) * 1000, Val(ESUM1.Value.Replace(",", String.Empty)) * 1000, Val(ESUM2.Value.Replace(",", String.Empty)) * 1000, Val(E1.Value.Replace(",", String.Empty)) * 1000, Val(E2.Value.Replace(",", String.Empty)) * 1000, Val(E3.Value.Replace(",", String.Empty)) * 1000, Val(E4.Value.Replace(",", String.Empty)) * 1000, Val(E5.Value.Replace(",", String.Empty)) * 1000, Val(E6.Value.Replace(",", String.Empty)) * 1000, Val(E7.Value.Replace(",", String.Empty)) * 1000, Val(E8.Value.Replace(",", String.Empty)) * 1000, Val(E9.Value.Replace(",", String.Empty)) * 1000, Val(E10.Value.Replace(",", String.Empty)) * 1000, Val(E11.Value.Replace(",", String.Empty)) * 1000, Val(E12.Value.Replace(",", String.Empty)) * 1000, Val(E13.Value.Replace(",", String.Empty)) * 1000, Val(E14.Value.Replace(",", String.Empty)) * 1000, Val(E15.Value.Replace(",", String.Empty)) * 1000, Val(E16.Value.Replace(",", String.Empty)) * 1000, Val(E17.Value.Replace(",", String.Empty)) * 1000, Val(E18.Value.Replace(",", String.Empty)) * 1000, Val(E19.Value.Replace(",", String.Empty)) * 1000, Val(E20.Value.Replace(",", String.Empty)) * 1000, Val(E21.Value.Replace(",", String.Empty)) * 1000, Val(E22.Value.Replace(",", String.Empty)) * 1000, Val(E23.Value.Replace(",", String.Empty)) * 1000, Val(E24.Value.Replace(",", String.Empty)) * 1000, Date.Now(), Val(Session("users")), Val(E_ID.Text))
            adapterX.UpdateQuery(Val(F_LAST2.Text), Val(FSUM0.Value.Replace(",", String.Empty)) / 100, Val(FSUM1.Value.Replace(",", String.Empty)) / 100, Val(FSUM2.Value.Replace(",", String.Empty)) / 100, Val(F1.Value.Replace(",", String.Empty)) / 100, Val(F2.Value.Replace(",", String.Empty)) / 100, Val(F3.Value.Replace(",", String.Empty)) / 100, Val(F4.Value.Replace(",", String.Empty)) / 100, Val(F5.Value.Replace(",", String.Empty)) / 100, Val(F6.Value.Replace(",", String.Empty)) / 100, Val(F7.Value.Replace(",", String.Empty)) / 100, Val(F8.Value.Replace(",", String.Empty)) / 100, Val(F9.Value.Replace(",", String.Empty)) / 100, Val(F10.Value.Replace(",", String.Empty)) / 100, Val(F11.Value.Replace(",", String.Empty)) / 100, Val(F12.Value.Replace(",", String.Empty)) / 100, Val(F13.Value.Replace(",", String.Empty)) / 100, Val(F14.Value.Replace(",", String.Empty)) / 100, Val(F15.Value.Replace(",", String.Empty)) / 100, Val(F16.Value.Replace(",", String.Empty)) / 100, Val(F17.Value.Replace(",", String.Empty)) / 100, Val(F18.Value.Replace(",", String.Empty)) / 100, Val(F19.Value.Replace(",", String.Empty)) / 100, Val(F20.Value.Replace(",", String.Empty)) / 100, Val(F21.Value.Replace(",", String.Empty)) / 100, Val(F22.Value.Replace(",", String.Empty)) / 100, Val(F23.Value.Replace(",", String.Empty)) / 100, Val(F24.Value.Replace(",", String.Empty)) / 100, Date.Now(), Val(Session("users")), Val(F_ID.Text))

            logger.Info("User " & Session("users") & " update product " & name1.Text)

            scripttext = "<script>ClosePop();</script>"
        Catch ex As Exception
            scripttext = "<script>alert('ไม่สามารถบันทึกได้เนื่องจากจำนวนเงินเกินค่าที่ระบบจะรับได้');</script>"
        End Try
    End Sub
End Class
